package edu.zju.gis.cky.cons;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * @author Zhou Yuquan
 * @version 1.0, 2021-11-20
 */
public class Constant {

    public static final String MODEL_PATH = "D:/Mine/Project2/CKY/models";

    public static final String USER_PATH = "D:/Mine/Project2/CKY/userspace";

    public static final String DATA_PATH = "D:/Mine/Project2/CKY/data";
    /**
     * 瓦片存放的根目录 实际目录组织形式 根目录/数据ID/z/x/y
     */
    public static final String TILE_PATH = "D:/tile";
    /**
     * TSV文本文件的根目录 实际目录组织形式 根目录/数据ID.tsv
     */
    public static final String TSV_PATH = "D:/tsv";
    /**
     * 切片程序临时文件根目录 实际目录组织形式 根目录/数据ID 结束后会被删除
     */
    public static final String TEMP_PATH = "D:/temp";

    public static final String TEMP_DATA_PATH = "D:/Mine/Project2/CKY/tempData";

    public static final String PG_HOST = "10.79.231.84";

    public static final int PG_PORT = 5432;

    public static final String PG_DATABASE = "cky";

    public static final String PG_USERNAME = "postgres";

    public static final String PG_PASSWORD = "postgres";

    public static final String VECTOR_SCHEMA = "vector";

    public static final String MODEL_SCHEMA = "model";

    public static final List<String> SHP_FILES_SUFFIX = Arrays.asList("shp", "shx", "sbx", "sbn", "prj", "dbf", "cpg");

    public static final String LOAD_BATCH_SIZE = "500000";

    public static final HashMap<String, String> CLASS_TO_NAME = new HashMap<String, String>() {{
        put("0303", "红树林地");
        put("0304", "森林沼泽");
        put("0306", "灌丛沼泽");
        put("0402", "沼泽草地");
        put("0603", "盐田");
        put("1105", "沿海滩涂");
        put("1106", "内陆滩涂");
        put("1108", "沼泽地");

        put("0101", "水田");
        put("0102", "水浇地");
        put("0103", "旱地");

        put("0201", "果园");
        put("0202", "茶园");
        put("0203", "橡胶园");
        put("0204", "其他园地");

        put("0301", "乔木林地");
        put("0302", "竹林地");
        put("0305", "灌木林地");
        put("0307", "其他林地");

        put("0401", "天然牧草池");
        put("0403", "人工牧草池");
        put("0404", "其他草地");

        put("05H1", "商业服务业设施用地");
        put("0508", "物流仓储用地");

        put("0601", "工业用地");
        put("0602", "采矿用地");

        put("0701", "城镇住宅用地");
        put("0702", "农村宅基地");

        put("08H1", "机关团体新闻出版用地");
        put("08H2", "科教文卫用地");
        put("0809", "公共设施用地");
        put("0810", "公园与绿地");

        put("09", "特殊用地");

        put("1001", "铁路用地");
        put("1002", "轨道交通用地");
        put("1003", "公路用地");
        put("1004", "城镇村道路用地");
        put("1005", "交通服务场站用地");
        put("1006", "农村道路");
        put("1007", "机场用地");
        put("1008", "港口码头用地");
        put("1009", "管道运输用地");

        put("1101", "河流水面");
        put("1102", "湖泊水面");
        put("1103", "水库水面");
        put("1104", "坑塘水面");
        put("1107", "沟渠");
        put("1109", "水工建筑用地");
        put("1110", "冰川及永久积雪");

        put("1201", "空闲地");
        put("1202", "设施农用地");
        put("1203", "田坎");
        put("1204", "盐碱地");
        put("1205", "沙地");
        put("1206", "裸土地");
        put("1207", "裸岩石砾地");
    }};

    public static final HashMap<String, String[]> ONE_TO_TWO = new HashMap<String, String[]>() {{
        put("00", new String[]{"0303", "0304", "0306", "0402", "0603", "1105", "1106", "1108"});
        put("01", new String[]{"0101", "0102", "0103"});
        put("02", new String[]{"0201", "0202", "0203", "0204", "0204K", "0203K", "0202K", "0201K"});
        put("03", new String[]{"0301", "0302", "0305", "0307", "0307K", "0301K", "0302K"});
        put("04", new String[]{"0401", "0403", "0404", "0403K"});
        put("05", new String[]{"05H1", "0508"});
        put("06", new String[]{"0601", "0602"});
        put("07", new String[]{"0701", "0702"});
        put("08", new String[]{"08H1", "08H2", "0809", "0810", "0810A"});
        put("09", new String[]{"09"});
        put("10", new String[]{"1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009"});
        put("11", new String[]{"1101", "1102", "1103", "1104", "1107", "1109", "1110", "1104A", "1107A"});
        put("12", new String[]{"1201", "1202", "1203", "1204", "1205", "1206", "1207"});
    }};

    public static final HashMap<String, String> K_UP = new HashMap<String, String>() {{
        put("0201K", "0201");
        put("0202K", "0202");
        put("0203K", "0203");
        put("0204K", "0204");
        put("0301K", "0301");
        put("0302K", "0302");
        put("0307K", "0307");
        put("0403K", "0403");
        put("1104K", "1104A");
    }};

    public static final HashMap<String, String> THREE_TYPE = new HashMap<String, String>() {{
        String[] type1 = new String[]{"0101", "0102", "0103", "0201", "0201K", "0202", "0202K", "0203", "0203K", "0204", "0204K", "0301", "0301K", "0302", "0302K", "0303", "0304", "0305", "0306", "0307", "0307K", "0401", "0402", "0403", "0403K", "1006", "1103", "1104", "1104A", "1104K", "1107", "1107A", "1202", "1203"};
        String[] type2 = new String[]{"05H1", "0508", "0601", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1001", "1002", "1003", "1004", "1005", "1007", "1008", "1009", "1109", "1201"};
        String[] type3 = new String[]{"0404", "1101", "1102", "1105", "1106", "1108", "1110", "1204", "1205", "1206", "1207"};
        for (String type : type1) {
            put(type, "农用地");
        }
        for (String type : type2) {
            put(type, "建设用地");
        }
        for (String type : type3) {
            put(type, "未利用地");
        }
    }};

    public static final HashMap<String, String[]> THREE_TO_TWO = new HashMap<String, String[]>() {{
        put("01", new String[]{"0101", "0102", "0103", "0201", "0201K", "0202", "0202K", "0203", "0203K", "0204K", "0204", "0301", "0301K", "0302", "0302K", "0303", "0304", "0305", "0306", "0307", "0307K", "0401", "0402", "0403", "0403K", "1006", "1103", "1104", "1104A", "1104K", "1107", "1107A", "1202", "1203"});
        put("02", new String[]{"05H1", "0508", "0601", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1001", "1002", "1003", "1004", "1005", "1007", "1008", "1009", "1109", "1201"});
        put("03", new String[]{"0404", "1101", "1102", "1105", "1106", "1108", "1110", "1204", "1205", "1206", "1207"});
    }};

    public static final HashMap<String, String> THREE_TYPE_NAME = new HashMap<String, String>() {{
        put("农用地", "01");
        put("建设用地", "02");
        put("未利用地", "03");
    }};

    public static final HashMap<String, String> ONE_CLASS = new HashMap<String, String>() {{
        put("00", "湿地");
        put("01", "耕地");
        put("02", "种植园用地");
        put("03", "林地");
        put("04", "草地");
        put("05", "商业服务业用地");
        put("06", "工矿用地");
        put("07", "住宅用地");
        put("08", "公共管理与公共服务用地");
        put("09", "特殊用地");
        put("10", "交通运输用地");
        put("11", "水域及水利设施用地");
        put("12", "其他土地");
    }};

    public static final HashMap<String, String> TWO_TO_ONE = new HashMap<String, String>() {{
        String[] wet = new String[]{"0303", "0304", "0306", "0402", "0603", "1105", "1106", "1108"};
        String[] culti = new String[]{"01", "0101", "0102", "0103"};
        String[] plant = new String[]{"02", "0201", "0201K", "0202", "0202K", "0203", "0203K", "0204", "0204K"};
        String[] woods = new String[]{"03", "0301", "0301K", "0302", "0302K", "0305", "0307", "0307K"};
        String[] grass = new String[]{"04", "0401", "0403", "0403K", "0404"};
        String[] business = new String[]{"05", "05H1", "0508"};
        String[] mining = new String[]{"06", "0601", "0602"};
        String[] residence = new String[]{"07", "0701", "0702"};
        String[] common = new String[]{"08", "08H1", "08H2", "08H2A", "0809", "0810", "0810A"};
        String[] special = new String[]{"09"};
        String[] traffic = new String[]{"10", "1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009"};
        String[] water = new String[]{"11", "1101", "1102", "1103", "1104", "1104A", "1107", "1107A", "1109", "1110"};
        String[] other = new String[]{"12", "1201", "1202", "1203", "1204", "1205", "1206", "1207"};

        for (String type : wet) {
            put(type, "00");
        }
        for (String type : culti) {
            put(type, "01");
        }
        for (String type : plant) {
            put(type, "02");
        }
        for (String type : woods) {
            put(type, "03");
        }
        for (String type : grass) {
            put(type, "04");
        }
        for (String type : business) {
            put(type, "05");
        }
        for (String type : mining) {
            put(type, "06");
        }
        for (String type : residence) {
            put(type, "07");
        }
        for (String type : common) {
            put(type, "08");
        }
        for (String type : special) {
            put(type, "09");
        }
        for (String type : traffic) {
            put(type, "10");
        }
        for (String type : water) {
            put(type, "11");
        }
        for (String type : other) {
            put(type, "12");
        }

    }};

    public static final String[] ONE_CLASS_NUMBER = new String[]{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};

    public static final String[] THREE_CLASS_NUMBER = new String[]{"01", "02", "03"};

    public static final String[] THREE_CLASS_NAME = new String[]{"农用地", "建设用地", "未利用地"};
}
